#!/bin/bash
cd /root

ls gcc-9.3.0.tar.gz ||wget https://repo.huaweicloud.com/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz
tar -zxvf gcc-9.3.0.tar.gz
cd gcc-9.3.0
#./contrib/download_prerequisites
#wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
#wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
#wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
#wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
wget https://mindx.obs.cn-south-1.myhuaweicloud.com/opensource/isl-0.16.1.tar.bz2 --no-check-certificate
wget https://mirrors.huaweicloud.com/gnu/gmp/gmp-6.1.0.tar.bz2 --no-check-certificate
wget https://mirrors.huaweicloud.com/gnu/mpfr/mpfr-3.1.4.tar.bz2 --no-check-certificate
wget https://mirrors.huaweicloud.com/gnu/mpc/mpc-1.0.3.tar.gz --no-check-certificate

./contrib/download_prerequisites
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/gcc9.3.0
make -j&nproc
make install




export PATH=/usr/local/gcc9.3.0/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/gcc9.3.0/lib64/:$LD_LIBRARY_PATH

echo 'export PATH=/usr/local/gcc9.3.0/bin/:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/gcc9.3.0/lib64/:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

gcc --version
g++ --version
